package com.xmg.server.order.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.xmg.server.order.mapper.OrderInfoMapper;
import com.xmg.shop.api.order.domain.OrderInfo;
import com.xmg.shop.api.order.page.PageResult;
import com.xmg.shop.api.order.query.OrderInfoQueryObject;
import com.xmg.shop.api.order.service.IOrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by Administrator on 2017/11/16.
 */
@Service
public class OrderServiceImpl implements IOrderInfoService {
    @Autowired
    private OrderInfoMapper orderInfoMapper;

    @Override
    public PageResult queryPage(OrderInfoQueryObject qo) {
        Long count = orderInfoMapper.queryPageCount(qo);
        if (count <= 0) {
            return PageResult.empty(qo.getPageSize());
        }
        List<OrderInfo> data = orderInfoMapper.queryPageData(qo);
        return new PageResult(data, count.intValue(), qo.getCurrentPage(), qo.getPageSize());
    }

    @Override
    public OrderInfo selectByPrimaryKey(Long id) {
        return orderInfoMapper.selectByPrimaryKey(id);
    }
}
